#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>

int main()
{

//    printf("printf: hello\n");
//    fprintf(stdout,"fprintf: aaaaaa\n");
//    char buffer[30] = {"write: hello\n"};
//    write(1,buffer,strlen(buffer));
//    fflush(stdout);
//    //创建子进程
//    fork();
//


   close(1);//关闭标准输出流
    int fd1 = open("log1.txt",O_CREAT | O_TRUNC | O_WRONLY,0666);
    int fd2 = open("log2.txt",O_CREAT | O_TRUNC | O_WRONLY,0666);
    int fd3 = open("log3.txt",O_CREAT | O_TRUNC | O_WRONLY,0666);
    int fd4 = open("log4.txt",O_CREAT | O_TRUNC | O_WRONLY,0666);
    
    printf("fd1: %d\n", fd1);
    printf("fd2: %d\n", fd2);
    printf("fd3: %d\n", fd3);
    printf("fd4: %d\n", fd4);

    fflush(stdout); //把这段代码屏蔽
    
    close(fd1);
    close(fd2);
    close(fd3);
    close(fd4);
    return 0;
}
